<template>
  <div class="theme-switcher">
    <div
      class="theme-option"
      v-for="theme in themes" 
      :key="theme.id"
      :class="{ active: activeTheme === theme.id }"
      @click="selectTheme(theme.id)"
    >
      <div class="theme-circle" :style="getThemeCircleStyle(theme)"></div>
      <div class="theme-label">{{ theme.name }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ThemeSwitcher',
  props: {
    themes: {
      type: Array,
      required: true,
      // 每个主题对象应包含 id, name, colors 属性
    },
    activeTheme: {
      type: String,
      required: true
    }
  },
  methods: {
    selectTheme(themeId) {
      this.$emit('change-theme', themeId);
    },
    getThemeCircleStyle(theme) {
      // 为每种主题设置不同的颜色
      let backgroundColor;
      
      switch(theme.id) {
        case 'blue':
          backgroundColor = '#1e88e5';
          break;
        case 'dark':
        case 'dark-blue':
          backgroundColor = '#263238';
          break;
        case 'green':
          backgroundColor = '#43a047';
          break;
        case 'teal':
          backgroundColor = '#00897b';
          break;
        case 'purple':
          backgroundColor = '#9c27b0';
          break;
        default:
          backgroundColor = theme.colors.primary;
      }
      
      return {
        backgroundColor
      };
    }
  }
}
</script>

<style scoped>
.theme-switcher {
  display: flex;
  justify-content: center;
  gap: 10px;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 25px;
  padding: 8px 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 500px;
  margin: 0 auto;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 20px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  border-radius: 20px;
  position: relative;
}

.theme-option.active {
  background-color: rgba(255, 255, 255, 0.15);
}

.theme-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  margin-bottom: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.8);
  transition: transform 0.2s;
}

.theme-option:hover .theme-circle {
  transform: scale(1.15);
}

.theme-option.active .theme-circle {
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.theme-label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  transition: all 0.2s;
}

.theme-option.active .theme-label {
  color: white;
}

@media (max-width: 576px) {
  .theme-switcher {
    padding: 6px;
    gap: 5px;
  }
  
  .theme-option {
    padding: 6px 10px;
  }
  
  .theme-circle {
    width: 20px;
    height: 20px;
    margin-bottom: 4px;
  }
  
  .theme-label {
    font-size: 11px;
  }
}
</style> 